<?php 
/* P3(c)

******************************************************************************
                                                                                      
                         __                                                        
                        /__)                                                       
                       /__        P3 - moving Technologie            
                        __)                                                          
                        __)                                                          
                                                                                        
                                                                                        
       Copyright 2009 by p3.co.at                                                                                 
                                                                                        
       visit www.p3.co.at to get more Informations 
       about Teriko - Betriebsdatenerfassung                                                                                 
       - it's not allowed to change this scripts
       - it's not allowed to remove this copyright-tag

       -- you can download the complete license   
          under http://www.teriko.org

 (c) by Patrik Pfaffenbauer and P3 (http://www.p3.co.at)

 | Programname: P3.Teriko
 | Authtor: P3.Verein
 | Coder: Patrik Pfaffenbauer
 | Version: 0.1

 | Change Index
 |_____________________________________________
 |                                             |
 |4.3.2010 Erstellung | Patrik Pfaffenbauer    |
 |_____________________________________________|

******************************************************************************

P3(c) */

class Holiday extends Base
{
	public function Holiday()
	{	
		$this->title = $GLOBALS['lang']->GetLanguage("Holiday", "title");
		$this->toolbar = true;
		$this->moduleID = 200;
		$this->permission = GetPermission($this->moduleID);
		
		if(PermissionCount($this->permission) == 0)
		{
			$this->allowed = false;
		}
	}
	
	public function Add()
	{		
		include("./_tables.php");
		$panel = new Panel();
		
		$panel->AddRow();
		$panel->AddComboBox("userid", $GLOBALS['lang']->GetLanguage("Member", "lastName"), "", $tbluser, "id", "lastName");
		$panel->AddRow();
		$panel->AddDateTextBox("insertDate", $GLOBALS['lang']->GetLanguage("Holiday", "insertDate"), "");
		
		$panel->AddHidden("action", "save");
		$panel->AddHidden("option", "member");
		
		$panel->Close();
	}
	public function Edit()
	{		
		
	}
	
	public function AnalysPost()
	{
		if($_POST['action'] == "add")
			$this->Add();
		else
			$this->Paint();
	}
	
	public function Activate()
	{
		
	}

	public function Paint()
	{
		include("./_tables.php");
		
		echo 
		'<div id="cpanel">';
				
		$dgv = new DataGridView("holiday", false, "");
		$dgv->AddHeader($GLOBALS['lang']->GetLanguage("Member", "firstName")." ".$GLOBALS['lang']->GetLanguage("Member", "lastName"), "30%", true);
		$dgv->AddHeader($GLOBALS['lang']->GetLanguage("Holiday", "insertDate"), "17%", true);
		$dgv->AddHeader($GLOBALS['lang']->GetLanguage("Holiday", "dateFrom"), "17%", true);
		$dgv->AddHeader($GLOBALS['lang']->GetLanguage("Holiday", "dateTo"), "17%", true);
		$dgv->AddHeader($GLOBALS['lang']->GetLanguage("Holiday", "acceptAsRead"), "17%", true);
		$dgv->AddHeader($GLOBALS['lang']->GetLanguage("Holiday", "acceptAsConfirmed"), "17%", true);
		$dgv->CloseHeader();
		
		$res = $GLOBALS['db']->Query("SELECT * FROM ".tblholiday);
		
		while($line = $GLOBALS['db']->Fetch($res))
		{
			$dgv->AddRow($line->id);
			$dgv->AddData($line->lastName." ".$line->firstName, "", "", "firstName lastName");
			$dgv->AddData($line->insertDate, "", "", "insertDate");
			$dgv->AddData($line->dateFrom, "", "", "dateFrom");
			$dgv->AddData($line->dateTo, "", "", "dateTo");
			
			if($this->permission->editPermission)
			{
				$dgv->AddData($line->acceptAsRead, "bool-fastEdit", "", "acceptAsRead");
				$dgv->AddData($line->acceptAsConfirmed, "bool-fastEdit", "", "acceptAsConfirmed");
			}
			else
			{
				$dgv->AddData($line->acceptAsRead, "bool", "", "acceptAsRead");
				$dgv->AddData($line->acceptAsConfirmed, "bool", "", "acceptAsConfirmed");
			}
			
			$dgv->CloseRow();
		}
		
		$dgv->CloseDataGrid();
		
		echo '</div>';
	}
	public function Toolbar()
	{
		if(!$this->allowed)
			return;
			
		PaintDefaultToolbar($this);
	}
	
	public function AddCSS()
	{
			
	}
	public function AddJS()
	{
		
	}
}

?>